#include "StatusLayer.h"

USING_NS_CC;

bool StatusLayer::init()
{
	if(!Layer::init())
	{
		return false;
	}

	Size visibleSize = Director::getInstance()->getVisibleSize();

	labelCoin = LabelTTF::create("Coin : 0", "Helvetica", 20);
	labelCoin->setColor(Color3B(0, 0, 0));
	labelCoin->setPosition(Vec2(70, visibleSize.height - 20));
	this->addChild(labelCoin);

	labelMeter = LabelTTF::create("0M", "Helvetica", 20);
	labelMeter->setPosition(Vec2(visibleSize.width - 70, visibleSize.height -20));
	this->addChild(labelMeter);

	return true;
}

void StatusLayer::updateMeter( float px )
{
	std::stringstream ss;
	ss << (int)(px/10) << "M";
	labelMeter->setString(ss.str());
}

void StatusLayer::addCoin(int num)
{
	coins += num;

	std::stringstream ss;
	ss << "Coin : " << coins;
	labelCoin->setString(ss.str());
}
